using Microsoft.Xna.Framework;
using System.Globalization;
using System.Collections.Generic;
using System.Xml;

namespace XeoEngine
{
    class SingleplayerScreen : MenuScreen
    {
        List<string> descriptions  = new List<string>();

        public SingleplayerScreen()
            : base(Localizations.Strings.Singleplayer)
        {
            int ln = 2;
            for (int i = 1; i <= ln; i++)
            {
                using (XmlReader reader = XmlReader.Create("Content/Levels/" + i.ToString() + ".xml"))
                {
                    reader.ReadStartElement("Level");
                    string name = Localizations.Strings.ResourceManager.GetString("lvl" + i.ToString() + "n", Localizations.Strings.Culture);
                    descriptions.Add(Localizations.Strings.ResourceManager.GetString("lvl" + i.ToString() + "d", Localizations.Strings.Culture));
                    reader.Close();
                    MenuEntry PlayMenuEntry = new MenuEntry(name);
                    PlayMenuEntry.Selected += PlayMenuEntrySelected;
                    MenuEntries.Add(PlayMenuEntry);
                }
            }
            MenuEntry back = new MenuEntry(Localizations.Strings.Back);
            back.Selected += OnCancel;
            MenuEntries.Add(back);
        }

        void PlayMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(ScreenManager, true, descriptions[selectedEntry], e.PlayerIndex, new GameplayScreen(selectedEntry + 1));
        }
    }
}
